package com.ferrlo.servlet;

import java.awt.Color;

import com.octo.captcha.component.image.backgroundgenerator.FunkyBackgroundGenerator;
import com.octo.captcha.component.image.color.SingleColorGenerator;
import com.octo.captcha.component.image.fontgenerator.TwistedRandomFontGenerator;
import com.octo.captcha.component.image.textpaster.DecoratedRandomTextPaster;
import com.octo.captcha.component.image.textpaster.TextPaster;
import com.octo.captcha.component.image.textpaster.textdecorator.BaffleTextDecorator;
import com.octo.captcha.component.image.textpaster.textdecorator.TextDecorator;
import com.octo.captcha.component.image.wordtoimage.ComposedWordToImage;
import com.octo.captcha.component.word.wordgenerator.RandomWordGenerator;
import com.octo.captcha.engine.image.ListImageCaptchaEngine;
import com.octo.captcha.image.ImageCaptchaFactory;
import com.octo.captcha.image.gimpy.GimpyFactory;

public class SampleListImageCaptchaEngine extends ListImageCaptchaEngine {

	@Override
	protected void buildInitialFactories() {
		//create text parser 
		 TextPaster randomPaster = new DecoratedRandomTextPaster(new Integer(4), 
		        new Integer(4), new SingleColorGenerator(Color.BLACK), 
		 new TextDecorator[] { new BaffleTextDecorator(new Integer(1), Color.WHITE) }); 
		 //create image captcha factory 
		 ImageCaptchaFactory factory = new GimpyFactory( 
		        new RandomWordGenerator("abcdefghijklmnopqrstuvwxyz"), 


		    new ComposedWordToImage(new TwistedRandomFontGenerator(new Integer(34), 
		            new Integer(34)), new FunkyBackgroundGenerator(new Integer( 
		            260), new Integer(70)), randomPaster)); 
		    
		 ImageCaptchaFactory characterFactory[] = { factory}; 
		 this.addFactories(characterFactory); 
	}

}
